<!DOCTYPE html>
<!--suppress ALL-->
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
    <title>发布房源</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=yes">
    <link rel="stylesheet" type="text/css" href="/css/pc/client/common.css">
    <!--[if lte IE 8]>
    <script src="/common/js/html5shiv.js"></script>
    <![endif]-->
    <script src="https://hm.baidu.com/hm.js?d6b1afd88bad903f6c136281ac832114"></script>
    <script type="text/javascript">
        var _hmt = _hmt || [];
        (function () {
            var href = window.location.href;
            if (!href.match('test') && !href.match('mt')) {
                var hm = document.createElement("script");
                hm.src = "https://hm.baidu.com/hm.js?d6b1afd88bad903f6c136281ac832114";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            }
        })();
    </script>
    <link rel="stylesheet" type="text/css" href="/css/pc/client/personal.css">
    <link rel="stylesheet" type="text/css" href="/css/pc/client/addApart.css">
    <link rel="stylesheet" href="/libs/webupload/webuploader.css">
</head>
<body>
<input type="hidden" th:value="${session.username}" name="username" id="username">
<input type="hidden" th:value="${cityId}" name="cityId" id="cityId">
<input type="hidden" th:value="${session.userId}" name="userId" id="userId">
<div class="header">
    <div class="nav-wrap">
        <div class="logo">
            <a rel="nofollow" href="#">
                <img src="/img/pc/client/home/logo.png" height="32" alt="租房网">
            </a>
        </div>
        <div class="city-wrap" style="cursor: default;">
            <span th:text="${cityName}"></span><i></i>
            <ul>
                    <span th:each="retAddress,status:${retAddressList}">
                        <span th:if="${retAddress.cityName} != ${cityName}">
                             <li><a rel="nofollow" th:href="@{/retPersonage/personage(id=${retAddress.id})}" th:text="${retAddress.cityName}"></a></li>
                        </span>
                    </span>
            </ul>
            <!-- <span>[<a rel="nofollow" href="https://www.zufun.cn/index" class="link" target="_blank">切换城市</a>]</span> -->
        </div>
        <div class="nav-items">
            <div class="nav-item">
                <a rel="nofollow" th:href="@{/retAddress/index}">首页</a>
            </div>

            <div class="nav-item">
                <a th:href="@{/retAddress/searchList}">租房</a>
            </div>

            <div class="nav-item">
                <a rel="nofollow" href="https://www.zufun.cn/platform" target="_blank">物业平台</a>
            </div>

            <div class="nav-item user-down-wrap" id="login_holder">
                <a href="#loginModal" rel="nofollow" data-toggle="modal" data-target="#loginModal">注册/登录</a>
            </div>
        </div>
    </div>
</div>
<!-- #main begin -->
<div id="container">
    <!-- 个人中心左边的导航 begin -->
    <div id="left_nav">
        <div class="per-info">
            <ul>
                <li>
                    <a href="/user">个人信息</a>
                </li>
                <li>
                    <a href="/user/message">
                        系统消息
                    </a>
                </li>
                <li>
                    <a href="/retPersonage/favorite">
                        我的收藏
                    </a>
                </li>
                <li>
                    <a href="user/appointment">
                        预约管理
                    </a>
                </li>
                <li>
                    <a href="/user/apt/index">
                        出租房源
                    </a>
                </li>
            </ul>
        </div>
    </div>
    <div id="main">
        <div class="con-title">发布房源</div>
        <div id="add_apart_msg" style="display: block">
            <ul class="tab">
                <li class="tab-item tab-item-default">1 基本信息</li>
                <li class="tab-item">2 上传图片</li>
            </ul>
            <!--content -->
            <div class="apt-form-wrap">
                <form id="add_apart_form"  novalidate="novalidate">
                    <div class="fm-item">
                        <div class="fm-input" id="select_ppt_wrap">
                            <span class="label">楼盘</span>
                            <div class="input-wrap ppt-name">
                                <input autocomplete="off" type="text" name="leaseOut" class="not-post" id="leaseOut">
                                <p id="att_top_floor-error" class="error" title="leaseOut"
                                   style="color: red;font-size: 10px"></p>
                            </div>
                        </div>
                        <div class="fm-input" id="select_region">
                            <span class="label">选择区域</span>
                            <div class="input-wrap">
                                 <select name="regionId" id="regionId" class="not-post">
                                     <option value ="0" selected = "selected">请选择区域</option>
                                     <span th:each="retRegion,index:${retRegionList}">
                                         <option  th:value="${retRegion.id}"><span th:text="${retRegion.cityName}"></span></option>
                                     </span>
                                 </select>
                                <p id="att_top_floor-error" class="error" title="regionId"
                                   style="color: red;font-size: 10px"></p>
                            </div>
                        </div>
                        <div class="fm-input" id="select_region">
                            <span class="label">选择乡镇</span>
                            <div class="input-wrap">
                                <select name="retPropertiesId" id="retPropertiesId" class="not-post" th:fragment="chuang">
                                    <option value ="0" selected = "selected">请选择乡镇</option>
                                    <span th:if="not ${#lists.isEmpty(retPropertiesList)}" th:each="retProperties,index:${retPropertiesList}">
                                         <option th:value="${retProperties.id}"><span th:text="${retProperties.properties}"></span></option>
                                     </span>
                                </select>
                                <p id="att_top_floor-error" class="error" title="retPropertiesId"
                                   style="color: red;font-size: 10px"></p>
                            </div>
                        </div>
                        <div class="fm-input">
                            <span class="label">出租类型</span>
                            <div class="input-wrap">
                                <select name="huxingId" id="att_rent_type">
                                    <option value="1" selected="selected">整租</option>
                                    <option value="2">合租</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="fm-item">
                        <div class="fm-input zhenzu-flag">
                            <span class="label">户型</span>
                            <div class="input-wraps">
                                <div class="input-wrap">
                                    <input type="text" name="retShi" id="retShi">
                                    <span>室</span>
                                    <p id="att_top_floor-error" class="error" title="retShi"
                                       style="color: red;font-size: 10px"></p>
                                </div>
                                <div class="input-wrap">
                                    <input type="text" name="retTing" id="retTing">
                                    <span>厅</span>
                                    <p id="att_top_floor-error" class="error" title="retTing"
                                       style="color: red;font-size: 10px"></p>
                                </div>
                                <div class="input-wrap">
                                    <input type="text" name="retWei" id="retWei">
                                    <span>卫</span>
                                    <p id="att_top_floor-error" class="error" title="retWei"
                                       style="color: red;font-size: 10px"></p>
                                </div>
                            </div>
                        </div>
                        <div class="fm-input hezu-flag none">
                            <span class="label">房间面积</span>
                            <div class="input-wrap">
                                <input type="text" name="measure" id="measure">
                                <span>㎡</span>
                                <p id="att_top_floor-error" class="error" title="measure"
                                   style="color: red;font-size: 10px"></p>
                            </div>
                        </div>
                        <div class="fm-input hezu-flag none">
                            <span class="label">总面积</span>
                            <div class="input-wrap">
                                <input type="text" name="zonMeasure" id="zonMeasure">
                                <span>㎡</span>
                                <p id="att_top_floor-error" class="error" title="zonMeasure"
                                   style="color: red;font-size: 10px"></p>
                            </div>
                        </div>
                        <div class="fm-input hezu-flag none">
                            <span class="label">房间数</span>
                            <div class="input-wrap">
                                <input type="text" name="retFanjianshu" id="retFanjianshu">
                                <p id="att_top_floor-error" class="error" title="retFanjianshu"
                                   style="color: red;font-size: 10px"></p>
                            </div>
                        </div>
                    </div>
                    <div class="fm-item" id="chengfu">
                        <div class="fm-input">
                            <span class="label">楼层</span>
                            <div class="input-wrap">
                                <input type="text" name="att_floor" id="att_floor">
                                <span>层</span>
                            </div>
                        </div>
                        <div class="fm-input">
                            <span class="label">总楼层</span>
                            <div class="input-wrap">
                                <input type="text" name="att_top_floor" id="att_top_floor">
                                <span>层</span>
                            </div>
                        </div>
                    </div>
                    <div class="fm-item zhenzu-flag">
                        <div class="fm-input zhenzu-flag">
                            <span class="label">面积</span>
                            <div class="input-wrap">
                                <input type="text" name="att_space" id="att_space">
                                <span>㎡</span>
                            </div>
                        </div>
                    </div>
                    <div class="fm-item">
                        <div class="fm-input">
                            <span class="label">租金</span>
                            <div class="input-wrap">
                                <input type="text" name="money" id="money">
                                <span>元/月</span>
                                <p id="att_top_floor-error" class="error" title="money"
                                   style="color: red;font-size: 10px"></p>
                            </div>
                        </div>
                        <div class="fm-input">
                            <span class="label">押付方式</span>
                            <div class="input-wrap">
                                <select name="paymentId" id="paymentId">
                                    <option value="1" selected = "selected">押一付一</option>
                                    <option value="2">押二付一</option>
                                    <option value="4">押一付三</option>
                                    <option value="3">押三付一</option>
                                </select>
                            </div>
                        </div>
                        <div class="fm-input">
                            <span class="label">最短租期</span>
                            <div class="input-wrap">
                                <select name="housingId" id="housingId">
                                    <option value="5" selected = "selected">不限</option>
                                    <option value="1">一个月</option>
                                    <option value="2">三个月</option>
                                    <option value="3">半年</option>
                                    <option value="4">一年</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="fm-item">
                        <div class="fm-input">
                            <span class="label">交通描述</span>
                            <div class="input-wrap att-note">
                                <input type="text" name="retJiaoton" id="retJiaoton" placeholder="非必填，150字以内...">
                            </div>
                        </div>
                    </div>
                    <div class="fm-item">
                        <div class="fm-input">
                            <span class="label">房源描述</span>
                            <div class="input-wrap att-note">
                                <input type="text" name="retDescribe" id="retDescribe" placeholder="非必填，150字以内...">
                            </div>
                        </div>
                    </div>
                    <div class="fm-item">
                        <div class="fm-skus">
									<span class="label">
									配套设施
								</span>
                            <div class="skus-wrap">
                                <label><input type="checkbox" value="36">床</label>
                                <label><input type="checkbox" value="1">厨房</label>
                                <label><input type="checkbox" value="2">热水器</label>
                                <label><input type="checkbox" value="6">空调</label>
                                <label><input type="checkbox" value="8">网络</label>
                                <label><input type="checkbox" value="10">电视</label>
                                <label><input type="checkbox" value="11">冰箱</label>
                                <label><input type="checkbox" value="13">洗衣机</label>
                                <label><input type="checkbox" value="14">衣柜</label>
                                <label><input type="checkbox" value="23">电梯</label>
                                <span class="btn" onclick="base.checkAll(this);">全选</span>
                                <span class="btn" onclick="base.cancelAll(this);">清空</span>
                            </div>
                        </div>
                    </div>
                    <div class="next-step">
                        <button class="default-btn" id="xiayibu">下一步</button>
                    </div>
                </form>
            </div>
        </div>
        <!-- 第二步上传图片 -->
        <div class="con-box none" id="add_apart_pic">
            <ul class="tab">
                <li class="tab-item">1 基本信息</li>
                <li class="tab-item tab-item-last">2 上传图片</li>
            </ul>
            <div class="pic-box">
                <div id="pic_apart_holder">

                </div>
                <div class="add-pic">
                    <div id="upload_holder" class="webuploader-container">
                        <div class="webuploader-pick"></div>
                        <div id="rt_rt_1ec1geq95sc211sn1ukr1jqloi41" style="position: absolute; top: 0px; left: 0px; width: 228px; height: 158px; overflow: hidden; bottom: auto; right: auto;">
                            <input id="upload" type="file" name="file" class="webuploader-element-invisible" multiple="multiple" accept="image/*">
                            <label id="chese" style="opacity: 0; width: 100%; height: 100%; display: block; cursor: pointer; background: rgb(255, 255, 255);"></label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="next-step">
                <span id="pic_callback" class="cancel-btn">返回</span>
                <!--<span id="temporary_apart" class="cancel-btn">暂存</span>-->
                <span id="add_apart" class="default-btn" data-id="">发布</span>
            </div>
        </div>
    </div>
    <!-- 个人中心的内容区域 end -->
</div>
<!-- /buldings -->
<div style="clear:both"></div>
<div class="new-footer" style="margin-top:20px;">
    <div class="site-zufun">
        <div class="site-info">
            <p>
                <a rel="nofollow" href="https://www.zufun.cn/about" target="_blank">关于我们</a><span>|</span>
                <a rel="nofollow" href="https://www.zufun.cn/question" target="_blank">常见问题</a><span>|</span>
                <a rel="nofollow" href="https://www.zufun.cn/business" target="_blank">商务合作</a><span>|</span>
                <a rel="nofollow" href="https://www.zufun.cn/job" target="_blank">招聘信息</a><span>|</span>
                <a rel="nofollow" href="https://www.zufun.cn/protocol" target="_blank">服务声明</a><span>|</span>
                <a rel="nofollow" href="javascript:void(0);" onclick="suggest();">意见反馈</a><span>|</span>
                <a rel="nofollow" href="/sitemap" target="_blank">网站地图</a>
            </p>
            <div class="call-us">
                <div class="qrcode-wrap">
                    <span style="display: block;line-height: 1.3;white-space: nowrap;letter-spacing:2px;position: absolute;right:-30px;top: 17px;color:#999;">下载APP</span>
                    <i class="icon icon-mobile" style="position:relative;right:60px;"></i>
                    <i class="icon icon-app-qrcode qrcode" style="left:-102px;"></i>
                </div>
                <div class="qrcode-wrap">
                    <span style="display: block;line-height: 1.3;white-space: nowrap;letter-spacing:2px;position: absolute;left:30px;top: 17px;color:#999;">关注公众号</span>
                    <i class="icon icon-weixin"></i>
                    <i class="icon icon-weixin-qrcode qrcode"></i>
                </div>
            </div>
        </div>
        <div class="site-copyright" style="text-align:left;">
            <p>©2015-2020 深圳易找房信息技术有限公司&nbsp;&nbsp;版权所有&nbsp;&nbsp;
                <a href="http://beian.miit.gov.cn" target="_blank" rel="nofollow">粤ICP备15073386号</a>
            </p>
            <span class="hotline" style="position: absolute;top: 30px;right: 0;font-size: 14px;">服务热线：132-6682-1881（9:00 - 18:00）</span>
        </div>
    </div>
</div>
<script id="suggest_tpl" type="text/html">
    <form id="suggest_form">
        <div class="form-group">
            <div class="textarea-group">
                <label>反馈内容</label>
                <textarea name="content" placeholder="欢迎提出您在使用过程中遇到的问题或宝贵建议，感谢您的支持。"></textarea>
            </div>
            <div class="input-group" style="height:100px;">
                <label>联系方式</label>
                <input type="text" name="email" placeholder="请留下您的手机或邮箱" style="margin-top:5px;" value="{{fu_mobile}}">
            </div>
            <div class="button-group">
                <input type="submit" value="提交反馈">
            </div>
        </div>
    </form>
</script>
<div class="modal" id="picCodeModal" tabindex="-1" role="dialog"></div>
<script src="/common/js/jquery-1.11.3.min.js"></script>
<script src="/libs/yzf/modules/yzf.tab.js"></script>
<script src="/libs/yzf/modules/yzf.modal.js"></script>
<script src="/libs/yzf/modules/yzf.button.js"></script>
<!--[if !IE]> -->
<script src="/js/pc/client/clientCommon.js"></script>
<!-- <![endif]-->
<!--[if gte IE 9]>
<script src="/js/pc/client/clientCommon.js"></script>
<![endif]-->
<!--[if lte IE 8]>
<script src="/common/js/jquery.cookie.js"></script>
<script src="/common/js/artForm.js"></script>
<script src="/common/js/md5.js"></script>
<script src="/common/js/base.js"></script>
<script src="/common/js/validateConfig.js"></script>
<script src="/common/js/jquery.validate.js"></script>
<script src="/js/pc/client/loginAndRegist2.js"></script>
<script src="/libs/artdialog/dist/dialog-min.js"></script>
<script src="/common/js/template.js"></script>
<script src="/common/js/jquery.lazyload.min.js"></script>
<![endif]-->
<!--[if lt IE 8]>
<script src="/libs/JSON-js-master/json2.js"></script>
<![endif]-->
<!--[if lt IE 10]>
<script src="/common/js/normalize.js"></script>
<![endif]-->
<script src="/libs/webupload/webuploader.nolog.min.js"></script>
<script src="/common/js/artForm.js"></script>
<script src="/js/pc/client/addApart.js"></script>
<script th:src="@{/lib/layui/layui.js}"></script>
<script type="text/javascript">
    layui.use(["element", "form", "laydate", "okLayer", "okUtils","jquery"], function () {
        let form = layui.form;
        let laydate = layui.laydate;
        let okLayer = layui.okLayer;
        let okUtils = layui.okUtils;
        let $ = layui.jquery;

        /*laydate.render({elem: "#birthday", type: "datetime"});

        form.verify({
            birthdayVerify: [/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))(\s(([01]\d{1})|(2[0123])):([0-5]\d):([0-5]\d))?$/, '日期格式不正确']
        });*/

        form.on("submit(add)", function (data) {
            okUtils.ajax(basePath + "/devuser/addUser", "post", data.field, true).done(function (response) {
                console.log(response);
                okLayer.greenTickMsg("添加成功", function () {
                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                });
            }).fail(function (error) {
                console.log(error)
            });
            return false;
        });
        c1();


        $("#add_apart_msg").css("display", "block");
        $("#add_apart_pic").css("display", "none");
        $("#xiayibu").click(function () {
            var reg = /^[\u4e00-\u9fa5]+$/;
            var leaseOut = $("#leaseOut").val();
            var retShi = $("#retShi").val();
            var retTing = $("#retTing").val();
            var retWei = $("#retWei").val();
            var money = $("#money").val();
            var retFanjianshu = $("#retFanjianshu").val();
            var zonMeasure = $("#zonMeasure").val();
            var measure = $("#measure").val();
            var regionId = $("#regionId option:selected").val();
            var retPropertiesId = $("#retPropertiesId option:selected").val();
            var flag = true;
            if ($("#att_rent_type option:selected").val() == 1) {
                if (leaseOut == "" || leaseOut == null) {
                    $("p[title='leaseOut']").html("请输入楼盘");
                    flag = false;
                } else {
                    $("p[title='leaseOut']").html("");
                }
                if(regionId == 0 || regionId == "" || regionId == null){
                    $("p[title='regionId']").html("请选择区域");
                    flag = false;
                }else{
                    $("p[title='regionId']").html("");
                }
                if(retPropertiesId == 0 || retPropertiesId == "" || retPropertiesId == null){
                    $("p[title='retPropertiesId']").html("请选择乡镇");
                    flag = false;
                }else{
                    $("p[title='retPropertiesId']").html("");
                }
                if (retShi == "" || retShi == null) {
                    $("p[title='retShi']").html("请输入室");
                    flag = false;
                } else {
                    if(!reg.test($("input[name='retShi']").val())){
                        $("p[title='retShi']").html("请输入汉字‘一’,‘二’....");
                        flag = false;
                    }else{
                        $("p[title='retShi']").html("");
                    }
                }
                if (retTing == "" || retTing == null) {
                    $("p[title='retTing']").html("请输入厅");
                    flag = false;
                } else {
                    if(!reg.test($("input[name='retTing']").val())){
                        $("p[title='retTing']").html("请输入汉字‘一’,‘二’....");
                        flag = false;
                    }else{
                        $("p[title='retTing']").html("");
                    }
                }
                if (retWei == "" || retWei == null) {
                    $("p[title='retWei']").html("请输入卫");
                    flag = false;
                } else {
                    if(!reg.test($("input[name='retWei']").val())){
                        $("p[title='retWei']").html("请输入汉字‘一’,‘二’....");
                        flag = false;
                    }else{
                        $("p[title='retWei']").html("");
                    }
                }
                if (money == "" || money == null) {
                    $("p[title='money']").html("请输入租金");
                    flag = false;
                } else {
                    $("p[title='money']").html("");
                }
            } else {
                if (leaseOut == "" || leaseOut == null) {
                    $("p[title='leaseOut']").html("请输入楼盘");
                    flag = false;
                } else {
                    $("p[title='leaseOut']").html("");
                }
                if(regionId == 0 || regionId == "" || regionId == null){
                    $("p[title='regionId']").html("请选择区域");
                    flag = false;
                }else{
                    $("p[title='regionId']").html("");
                }
                if (measure == "" || measure == null) {
                    $("p[title='measure']").html("请输入面积");
                    flag = false;
                } else {
                    $("p[title='measure']").html("");
                }
                if (zonMeasure == "" || zonMeasure == null) {
                    $("p[title='zonMeasure']").html("请输入总面积");
                    flag = false;
                } else {
                    $("p[title='zonMeasure']").html("");
                }
                if (retFanjianshu == "" || retFanjianshu == null) {
                    $("p[title='retFanjianshu']").html("请输入房间数");
                    flag = false;
                } else {
                    $("p[title='retFanjianshu']").html("");
                }
                if (money == "" || money == null) {
                    $("p[title='money']").html("请输入租金");
                    flag = false;
                } else {
                    $("p[title='money']").html("");
                }
            }
            if (flag == true) {
                $("#add_apart_msg").css("display", "none");
                $("#add_apart_pic").css("display", "block");
            }
        });

        $("#pic_callback").click(function () {
            $("#add_apart_msg").css("display", "block");
            $("#add_apart_pic").css("display", "none");
        })


        //为外面的盒子绑定一个点击事件
        $("#chese").click(function(){
            $("#upload").click();
           f1();
        })
        var c2 = 0;
        function f1() {
            var $input = $("#upload");
            if(c2 == 0){
                $input.on("change" , function(){

                    //获取选择图片的个数
                    var files = this.files;
                    var length = files.length;
                    //3、回显
                    //var zhi  = $("#pic_apart_holder").children().length;
                    //调它的readAsDataURL并把原生File对象传给它，
                    //var formData = new FormData(this.files[0]);
                    console.log(this.files)
                    $.each(files,function(key,value){
                        var fr = new FileReader()
                        fr.onloadend = function(e){
                            $("#pic_apart_holder").append("<div class='pic-holder apart_pic' data-type='application/octet-stream'>" +
                                "<div class='show_trangle' data-status='0'><span class='icon icon-trash' onclick='deletePic(this);'></span>" +
                                "<span class='biaoji' style='display: none'><div class='pic_trangle'></div><span id='feng'>封</span></span></div>" +
                                "<img src='"+ this.result +"'></div>")
                            $("#pic_apart_holder div:first .biaoji").css("display","");
                        }
                        fr.readAsDataURL(value);
                    })
                })
                c2++;
            }
        }

        $("#add_apart").click(function () {
            "加载中..." != $(this).text() && 0 < $("#pic_apart_holder .apart_pic").length ? ($(this).text("加载中..."),pao()) : $("#pic_apart_holder .apart_pic").length <= 0 && base.alertMsg({text: "请上传图片"})
        })

        function pao(){
            if($("#att_rent_type option:selected").val() == 1){
                //楼盘
                var leaseOut = $("#leaseOut").val();
                //城市
                var addressId = $("#cityId").val();
                //区域
                var regionId = $("#regionId option:selected").val();
                //乡镇
                var retPropertiesId = $("#retPropertiesId option:selected").val();
                //出租类型
                var huxingId = $("#att_rent_type option:selected").val();
                //室
                var retShi = $("#retShi").val();
                //厅
                var retTing = $("#retTing").val();
                //卫
                var retWei = $("#retWei").val();
                //楼层
                var retFanjianshu = $("#att_floor").val();
                //总楼层
                var zonMeasure = $("#att_top_floor").val();
                //面积
                var measure = $("#att_space").val();
                //租金
                var money = $("#money").val();
                //押付方式
                var paymentId = $("#paymentId option:selected").val();
                //租期
                var housingId = $("#housingId option:selected").val();
                //交通描述
                var retJiaoton = $("#retJiaoton").val();
                //房源描述
                var retDescribe = $("#retDescribe").val();
                //用户id
                var userId = $("#userId").val();

                // alert(retFanjianshu)
                $.ajax({
                    url: "/retPersonage/fanyuanAdd",        //后台url
                    data: {"leaseOut":leaseOut,"addressId":addressId,"regionId":regionId,"retPropertiesId":retPropertiesId,"huxingId":huxingId,"retShi":retShi,"retTing":retTing,"retWei":retWei,"retFanjianshu":retFanjianshu,"zonMeasure":zonMeasure,"measure":measure,"money":money,"paymentId":paymentId,"housingId":housingId,"retJiaoton":retJiaoton,"retDescribe":retDescribe,"userId":userId},
                    type: "POST",                   //类型，POST或者GET
                    dataType: 'json',              //数据返回类型，可以是xml、json等
                    success: function (data) {      //成功，回调函数
                        if (data == "0") {
                            tupian();
                        } else {
                            alert("失败");
                        }
                    },
                    error: function (er) {          //失败，回调函数
                        alert(er);
                    }
                });
            }else{
                //楼盘
                var leaseOut = $("#leaseOut").val();
                //城市
                var addressId = $("#cityId").val();
                //区域
                var regionId = $("#regionId option:selected").val();
                //乡镇
                var retPropertiesId = $("#retPropertiesId option:selected").val();
                //出租类型
                var huxingId = $("#att_rent_type option:selected").val();
                //室
                var retShi = $("#retShi").val();
                //厅
                var retTing = $("#retTing").val();
                //卫
                var retWei = $("#retWei").val();
                //楼层
                var retFanjianshu = $("#retFanjianshu").val();
                //总楼层
                var zonMeasure = $("#zonMeasure").val();
                //房间面积
                var measure = $("#measure").val();
                //租金
                var money = $("#money").val();
                //押付方式
                var paymentId = $("#paymentId option:selected").val();
                //租期
                var housingId = $("#housingId option:selected").val();
                //交通描述
                var retJiaoton = $("#retJiaoton").val();
                //房源描述
                var retDescribe = $("#retDescribe").val();
                //用户id
                var userId = $("#userId").val();

                // alert(retFanjianshu)
                $.ajax({
                    url: "/retPersonage/fanyuanAdd",        //后台url
                    data: {"leaseOut":leaseOut,"addressId":addressId,"regionId":regionId,"retPropertiesId":retPropertiesId,"huxingId":huxingId,"retShi":retShi,"retTing":retTing,"retWei":retWei,"retFanjianshu":retFanjianshu,"zonMeasure":zonMeasure,"measure":measure,"money":money,"paymentId":paymentId,"housingId":housingId,"retJiaoton":retJiaoton,"retDescribe":retDescribe,"userId":userId},
                    type: "POST",                   //类型，POST或者GET
                    dataType: 'json',              //数据返回类型，可以是xml、json等
                    success: function (data) {      //成功，回调函数
                        if (data == "0") {
                            tupian();
                        } else {
                            alert("失败");
                        }
                    },
                    error: function (er) {          //失败，回调函数
                        alert(er);
                    }
                });
            }
        }


        function tupian(){
            var form = new FormData();
            for(var i=0;i<$("#upload")[0].files.length;i++){
                form.append("file", $("#upload")[0].files[i]);
            }
            $.ajax({
                url: "/retPersonage/informationadd",        //后台url
                data: form,
                cache: false,
                async: false,
                type: "POST",                   //类型，POST或者GET
                dataType: 'json',              //数据返回类型，可以是xml、json等
                processData: false,
                contentType: false,
                success: function (data) {      //成功，回调函数
                    if (data.result == 1) {
                        window.location = "/retPersonage/apt/index";
                    } else {
                        alert("失败");
                    }
                },
                error: function (er) {          //失败，回调函数
                    alert(er);
                }
            });
        }


        $("#regionId").change(function () {
            var regionId = $("#regionId option:selected").val();
            $("#retPropertiesId").load("/retPersonage/propertiesId?id="+regionId);
        })

    });

    function c1() {
        var user = $("#username").val();
        var t = $("#login_holder");
        user ? t.html('<div class="drop-wrap"><a href="/retPersonage/personage"><span class="icon_user"></span><span>' + user + '</span></a><ul class="arrow-top nav-down-wrap"><li><a href="/retPersonage/personage" target="_blank">个人中心</a></li><li><a href="/retAddress/logout" data-toggle="logout">退出登录</a></li></ul>') : t.html('<a href="#loginModal" rel="noffolow" data-toggle="modal" data-target="#loginModal">注册/登录</a>')
    }
    var aptNewHandler = function () {
        var $parent = $("#add_apart_form"),
            $apartData = null,
            $regions = null,
            $items = null;

        /**
         * 图片加载效果：
         * @Author   King
         * @DateTime 2015-10-05T09:04:26+0800
         */
        function spinner_pic() {
            $('#pic_apart_holder').append('<div class="pic-holder spinner_pic"><span class="icon-spin"></span></div>');
        }


        //保存房源
        $parent.validate({
            rules: base.validate_config('apart').rules,
            messages: base.validate_config('apart').messages,
            submitHandler: function (e) {
                var data = artForm.getData(e);

                if (1 == data.att_rent_type) {
                    data.att_title = '整租' + base.numToChinese(data.att_rooms) + '居';
                } else {
                    data.att_title = '合租' + base.numToChinese(data.att_rooms) + '居';
                }

                //保存数据；
                $items = data.items;
                delete data.items;
                $apartData = data;
            }
        });


        //整租合租切换；
        $parent.find("#att_rent_type").change(function () {
            switch (this.value) {
                case '1': //整租
                    $(".zhenzu-flag").show();
                    $(".hezu-flag").hide();
                    $("#chengfu").show();
                    break;
                case '2': //合租
                    $(".zhenzu-flag").hide();
                    $(".hezu-flag").show();
                    $("#chengfu").hide();
                    break;
            }
        });
    }();
</script>
<div id="drop_tips_wrap" class="drop-tips-wrap" style="top: 257px; left: 691.5px; width: 306px; display: none;"></div>
</body>
</html>